<template>
  <div class="container is-scroll-bar">
    <div
      class="main-content is-scroll-bar"
      style="flex-direction: column; display: flex"
    >
      <div class="header-container">
        <el-menu
          :default-active="activeIndex"
          mode="horizontal"
          @select="handleSelect"
          class="title"
          style="width: 100%"
        >
          <el-submenu index="2">
            <template slot="title">目标职责</template>
            <el-menu-item index="2-1">目标</el-menu-item>
            <el-submenu index="2-2">
              <template slot="title">机构和职责</template>
              <el-menu-item index="2-2-1"
                ><a href="#/organization">机构设置</a></el-menu-item
              >
              <el-menu-item index="2-2-2"
                ><a href="#/safetymanagement"
                  >主要负责人及领导层职责</a
                ></el-menu-item
              >
            </el-submenu>
            <el-submenu index="2-3">
              <template slot="title">全员参与</template>
              <el-menu-item index="2-3-1"
                >安全生产责任制适宜性评估表</el-menu-item
              >
              <el-menu-item index="2-3-2"
                >安全生产责任制履行情况考核表</el-menu-item
              >
            </el-submenu>
            <el-submenu index="2-4">
              <template slot="title">安全生产投入</template>
              <el-menu-item index="2-4-1">安全生产投入计划</el-menu-item>
              <el-menu-item index="2-4-2">安全费用使用台账</el-menu-item>
            </el-submenu>
            <el-submenu index="2-5">
              <template slot="title">安全文化建设</template>
              <el-menu-item index="2-5-1"
                >企业开展安全文化建设活动台账</el-menu-item
              >
            </el-submenu>
            <el-menu-item index="2-6">安全生产信息化建设</el-menu-item>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title">制度化管理</template>
            <el-menu-item index="3-1">法规、标准、文件</el-menu-item>
            <el-submenu index="3-2">
              <template slot="title">规章制度</template>
              <el-menu-item index="3-2-1">
                <a href="#/safetyregulations">安全生产规章制度</a>
              </el-menu-item>
              <el-menu-item index="3-2-2"
                >工会及从业人员意见和建议表
              </el-menu-item>

              <el-menu-item index="3-2-3">
                <a href="#/safetyoperatingprocedures">安全操作规程</a>
              </el-menu-item>
              <el-menu-item index="3-2-4">修订意见和建议表 </el-menu-item>
              <el-menu-item index="3-2-5">
                <a href="#/businessprofile">操作规程传达的学习记录</a>
              </el-menu-item>
            </el-submenu>
            <!-- 文档管理 -->
            <el-submenu index="3-3">
              <template slot="title">文档管理</template>
              <el-menu-item index="3-3-1"> 会议记录 </el-menu-item>
            </el-submenu>
          </el-submenu>
          <!-- 教育培训 -->
          <el-submenu index="3-4">
            <template slot="title">教育培训</template>
            <el-menu-item index="3-4-1">
              <a href="#/businessprofile">安全教育培训</a>
            </el-menu-item>
            <el-menu-item index="3-4-2"> 外来人员培训记录 </el-menu-item>
          </el-submenu>
          <!-- 现场管理 -->
          <el-submenu index="3-5">
            <template slot="title">现场管理</template>
            <el-menu-item index="3-5-1"> 设备设施管理 </el-menu-item>
            <el-menu-item index="3-5-2">
              <a href="#/outsourcedmanagement">作业安全</a>
            </el-menu-item>
            <el-menu-item index="3-5-3"> 职业健康 </el-menu-item>
          </el-submenu>
          <!-- 安全风险管控及隐患排查治理 -->
          <el-menu-item index="3-6">
            <a href="#/hiddendangerinvestigation">安全风险管控及隐患排查治理</a>
          </el-menu-item>
          <el-menu-item index="3-7">
            <a href="#/emergencymanagement">应急管理</a>
          </el-menu-item>
          <el-submenu index="3-8">
            <template slot="title">事故查处</template>
            <el-menu-item index="3-8-1"> 事故报告表 </el-menu-item>
            <el-menu-item index="3-8-2">
              <a href="#/personalprofile">调查和处理</a>
            </el-menu-item>
            <el-menu-item index="3-8-3"> 事故管理台账 </el-menu-item>
          </el-submenu>
          <el-submenu index="3-9">
            <template slot="title">持续改进</template>
            <el-menu-item index="3-9-1"> 绩效评定 </el-menu-item>
            <el-menu-item index="3-9-2"> 持续改进 </el-menu-item>
          </el-submenu>
          <!--  -->
        </el-menu>
      </div>
      <div class="main">
        <transition name="fade-right" mode="out-in">
          <router-view></router-view>
        </transition>
      </div>
    </div>
  </div>
</template>

<script setup>
import { defineProps, defineComponent, ref } from "vue";
import router from "@/router";
const props = defineProps();
const message = "Hello, Vue 3!";
const activeIndex = ref("1-1");
const NewComponentName = defineComponent({
  name: "SafetyManagementIndex",
  setup() {
    return {
      message,
    };
  },
});

console.log(props);
console.log(NewComponentName);

const handleSelect = (key, keyPath) => {
  console.log(key, keyPath);
  if (key == "2-1") {
    if (router.currentRoute.path !== "/standardization") {
      router.push("/standardization");
    }
  } else if (key == "2-3-1") {
    if (router.currentRoute.path !== "/suitabilityassessmentform") {
      router.push("/suitabilityassessmentform");
    }
  } else if (key == "2-3-2") {
    if (router.currentRoute.path !== "/situationappraisalform") {
      router.push("/situationappraisalform");
    }
  } else if (key == "2-4-1") {
    if (router.currentRoute.path !== "/productioninputplan") {
      router.push("/productioninputplan");
    }
  } else if (key == "2-4-2") {
    if (router.currentRoute.path !== "/securityexpensesledgers") {
      router.push("/securityexpensesledgers");
    }
  } else if (key == "2-5-1") {
    if (router.currentRoute.path !== "/culturalconstructionledger") {
      router.push("/culturalconstructionledger");
    }
  } else if (key == "3-1") {
    if (router.currentRoute.path !== "/lowfile") {
      router.push("/lowfile");
    }
  } else if (key == "3-2-2") {
    if (router.currentRoute.path !== "/commentssuggestions") {
      router.push("/commentssuggestions");
    }
  }
  //
  else if (key == "3-2-4") {
    if (router.currentRoute.path !== "/commentssuggestions2") {
      router.push("/commentssuggestions2");
    }
  }
  //
  else if (key == "3-3-1") {
    if (router.currentRoute.path !== "/minutesmeeting") {
      router.push("/minutesmeeting");
    }
  }
  //3-4-2
  else if (key == "3-4-2") {
    if (router.currentRoute.path !== "/foreignpersonneltraining") {
      router.push("/foreignpersonneltraining");
    }
  } else if (key == "3-5-3") {
    if (router.currentRoute.path !== "/occupationalhealth") {
      router.push("/occupationalhealth");
    }
  }
  //
  else if (key == "3-8-1") {
    if (router.currentRoute.path !== "/accidentreportform") {
      router.push("/accidentreportform");
    }
  }
  // incidentmanagementledger
  else if (key == "3-8-3") {
    if (router.currentRoute.path !== "/incidentmanagementledger") {
      router.push("/incidentmanagementledger");
    }
  }
  // selfevaluationreport
  else if (key == "3-9-1") {
    if (router.currentRoute.path !== "/selfevaluationreport") {
      router.push("/selfevaluationreport");
    }
  }
  // continuousimprovement
  else if (key == "3-9-2") {
    if (router.currentRoute.path !== "/continuousimprovement") {
      router.push("/continuousimprovement");
    }
  }
  // else if (key == "3-1") {
  //     if (router.currentRoute.path !== "/corporateproductionresponsibility") {
  //       router.push("/corporateproductionresponsibility");
  //     }
  //   } else if (key == "3-2") {
  //     if (router.currentRoute.path !== "/productionpostresponsibilities") {
  //       router.push("/productionpostresponsibilities");
  //     }
  //   } else if (key == "3-3") {
  //     if (router.currentRoute.path !== "/institutionalsystem") {
  //       router.push("/institutionalsystem");
  //     }
  //   } else if (key == "3-4") {
  //     if (router.currentRoute.path !== "/riskidentification") {
  //       router.push("/riskidentification");
  //     }
  //   } else if (key == "3-5") {
  //     if (router.currentRoute.path !== "/jobprocedures") {
  //       router.push("/jobprocedures");
  //     }
  //   } else if (key == "3-6") {
  //     if (router.currentRoute.path !== "/dailysecuritychecks") {
  //       router.push("/dailysecuritychecks");
  //     }
  //   } else if (key == "3-7") {
  //     if (router.currentRoute.path !== "/emergencysupportsystem") {
  //       router.push("/emergencysupportsystem");
  //     }
  //   } else if (key == "3-8") {
  //     if (router.currentRoute.path !== "/outsourcedprojectmanagement") {
  //       router.push("/outsourcedprojectmanagement");
  //     }
  //   }
};
</script>

<style lang="scss" scoped>
:deep(.main) {
  height: 100%;
}
:deep(.el-menu--horizontal > .el-submenu .el-submenu__title) {
  height: 54px;
  line-height: 54px;
}
.fade-right-enter-active,
.fade-right-leave-active {
  transition: opacity 0.1s;
}
.fade-right-enter,
.fade-right-leave-to {
  opacity: 0;
}

body {
  min-height: 100vh;

  transition: all 0.3s ease;
}
.container {
  padding: 15px;
  box-sizing: border-box;

  .main-content {
    background-color: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 6px;
    min-width: 700px;
    .header-container {
      padding: 15px 15px;
      box-sizing: border-box;
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;

      .title {
        position: relative;
        font-weight: bold;
        color: #333;
        font-size: 15px;
        padding-left: 16px;

        &::before {
          content: "";
          width: 3px;
          height: 19px;
          background-color: #82a848;
          left: 5px;
          top: calc(50% - 19px);
          position: absolute;
        }

        &::after {
          content: "";
          width: 3px;
          height: 16px;
          background-color: #82a848;
          left: 5px;
          top: calc(50% - 8px);
          position: absolute;
        }
      }
    }
  }
}

.main {
  padding: 12px 15px;
}

.w-100 {
  width: 100%;
}

.item-form-content {
  display: flex;
  flex-direction: row;
  align-items: center;

  i {
    margin: 0 10px;
  }
}

.productList-content {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  height: 40px;
}

.form-content {
  padding: 0 10px;
}

.dialog-action-bar {
  text-align: center;
  margin-top: 30px;
}
</style>
